<!DOCTYPE html>
<html>
<head>
    <?php include(__DIR__ . '/../Public/header.php'); ?>
    <style type="text/css">

    </style>
</head>
<body class="skin-black fixed">
<?php include(__DIR__ . '/../Public/nav.php'); ?>
<div class="wrapper row-offcanvas row-offcanvas-left">
    <?php include(__DIR__ . '/../Public/left.php'); ?>
    <aside class="right-side">
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <ul class="breadcrumb">
                        <li><a href="#"><i class="fa fa-home"></i> <?=L('ucenter',1)?></a></li>
                        <li class="active"><?=L('uchelp',1)?></li>
                    </ul>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="panel">
                        <header class="panel-heading"><?=L('my_help',1)?> </header>
                        <div class="panel-body">
                            <div class="box-tools m-b-15 clearfix">
                                <div class="input-group pull-left">
                                    <div class="pull-left">
                                    <input type="text" class="form-control input-sm pull-left" name='info[title]' placeholder="<?=L('search')?>" style="width: 150px;display:inline-block;margin-right:-1px">
                                        <div class="input-group-btn">
                                            <button class="btn btn-sm btn-default"  id='myFaqSearchBtn'><i class="fa fa-search"></i></button>
                                        </div>
                                    </div>
                                </div>
                                <button class="btn btn-sm btn-default pull-right" href="#addFaq" data-toggle="modal"><?=L('submit',1)?></button>
                            </div>
                            <div id='myFaqList'  data-url="<?=url('uchelp/get_my_faq')?>">
                        </div>
                    </div>
                </div>
            </div>
        </section><!-- /.content -->

        <?php include(__DIR__ . '/../Public/copyright.php'); ?>
    </aside><!-- /.right-side -->
</div><!-- ./wrapper -->
<div aria-hidden="true" role="dialog" tabindex="-1" id="addFaq" class="modal fade">
    <div class="modal-dialog" >
        <div class="modal-content">
            <div class="modal-header">
                <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                <h4 class="modal-title"><?=L('faq',2)?></h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal add_faq_form" data-action='<?=url('uchelp/add')?>' role="form" onsubmit="return false;">
                    <div class="form-group">
                        <label for="codeInput" class="col-lg-2 col-sm-2 control-label"><?=L('title',2)?></label>
                        <div class="col-lg-10">
                            <input type="text" class="form-control" name='info[title]' id="codeInput" data-rule-required="true">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="codeInput" class="col-lg-2 col-sm-2 control-label"><?=L('text',2)?></label>
                        <div class="col-lg-10">
                            <textarea class="form-control" name='info[text]' data-rule-required="true"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-10">
                            <button type="submit" class="btn btn-danger" ><?=L('submit',1)?></button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id='myFaqListTpl'>
    <table class="table table-bordered">
        <tr>
            <th style="width: 10%"><?=L('id',2)?></th>
            <th><?=L('title',2)?></th>
            <th style="width: 10%"><?=L('status',2)?></th>
            <th style="width: 10%"><?=L('action',2)?></th>
        </tr>
        <%_.each(data.list,function(item,ind){%>
        <tr>
            <td><%= item.id %></td>
            <td><%= item.title %></td>
            <td>
                <% if(item.status==0){%>
                <span class="badge bg-red"><?=L('pending',2)?></span>
                <% }else if(item.status==1){%>
                <span class="badge bg-green"><?=L('processing',2)?></span>
                <% }else if(item.status==2){%>
                <span class="badge bg-light-blue"><?=L('processed',2)?></span>
                <%}%>
            </td>
            <td><a href="<%= item.detail %>"><?=L('detail',2)?></a></td>
        </tr>
        <%})%>
    </table>
    <div class="table-foot"><%=data.page%></div>
</script>
<?php include(__DIR__ . '/../Public/footer.php'); ?>
<script type="text/javascript">
$(function(){
    getMyFaqList($('#myFaqList').attr('data-url'));
    $('#myFaqList').on('click','.table-foot a',function(e){
        e.preventDefault();
        getMyFaqList($(this).attr('href'));
    });
    $('#myFaqSearchBtn').on('click',function(){
        var me = $(this);
        var url = $('#myFaqList').attr('data-url');
        var data = {
            'title':me.parent().parent().parent().find('[name="info[title]"]').val()
        };
        getMyFaqList(url,data);
    })
    //获得我的工单
    function getMyFaqList(url,data){
        _.each(data,function(v,k){
            if(k){
                url +='/'+k+'/'+v;
            }
        })
        $.get(url,function(data){
            $('#myFaqList').html(
                _.template(
                    $('#myFaqListTpl').html(),
                    {variable: 'data'}
                )(data)
            );
        })
    }
})
</script>
</body>
</html>